/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

import DAO.StaffBean;
import entity.Assignment;
import entity.Entity_Class;
import entity.Mark;
import entity.Student;
import entity.SubmitOfAssignment;
import java.util.List;
import java.util.Vector;
import javax.ejb.EJB;

/**
 *
 * @author ZERO
 */
public class Staff {

    @EJB
    private StaffBean staffBean;
    public static entity.Staff staff;
    public static entity.Entity_Class entity_Class;
    public static List<Entity_Class> classes;
    public static Student student;
    public static List<Student> ses;
    public static String clid;
    private String studentname;
    public static List<Assignment> as;
    public static List<Assignment> as1;
    public static List<Mark> msg;
    public static List<Mark> msk;
    public static List<Mark> mstb;
    private String totalg;
    private String totalk;
    private String totaltb;
    public static List<SubmitOfAssignment> soas;
    private float mark;

    public float getMark() {
        return mark;
    }

    public void setMark(float mark) {
        this.mark = mark;
    }

    public List<SubmitOfAssignment> getSoas() {
        return soas;
    }

    public void setSoas(List<SubmitOfAssignment> soas) {
        Staff.soas = soas;
    }

    public String getTotalg() {
        return totalg;
    }

    public void setTotalg(String totalg) {
        this.totalg = totalg;
    }

    public String getTotalk() {
        return totalk;
    }

    public void setTotalk(String totalk) {
        this.totalk = totalk;
    }

    public String getTotaltb() {
        return totaltb;
    }

    public void setTotaltb(String totaltb) {
        this.totaltb = totaltb;
    }

    public List<Mark> getMsg() {
        return msg;
    }

    public void setMsg(List<Mark> msg) {
        Staff.msg = msg;
    }

    public List<Mark> getMsk() {
        return msk;
    }

    public void setMsk(List<Mark> msk) {
        Staff.msk = msk;
    }

    public List<Mark> getMstb() {
        return mstb;
    }

    public void setMstb(List<Mark> mstb) {
        Staff.mstb = mstb;
    }

    public List<Assignment> getAs() {
        return as;
    }

    public void setAs(List<Assignment> as) {
        Staff.as = as;
    }

    public List<Assignment> getAs1() {
        return as1;
    }

    public void setAs1(List<Assignment> as1) {
        Staff.as1 = as1;
    }

    public String getClassid() {
        return clid;
    }

    public void setClassid(String clid) {
        this.clid = clid;
    }

    public String getStudentname() {
        return studentname;
    }

    public void setStudentname(String studentname) {
        this.studentname = studentname;
    }

    public Student getStudent() {
        return student;
    }

    public void setStudent(Student student) {
        Staff.student = student;
    }

    public List<Student> getSes() {
        return ses;
    }

    public void setSes(List<Student> ses) {
        Staff.ses = ses;
    }

    public Entity_Class getEntity_Class() {
        return entity_Class;
    }

    public void setEntity_Class(Entity_Class entity_Class) {
        Staff.entity_Class = entity_Class;
    }

    public List<Entity_Class> getClasses() {
        return classes;
    }

    public void setClasses(List<Entity_Class> classes) {
        Staff.classes = classes;
    }

    public entity.Staff getStaff() {
        return staff;
    }

    public void setStaff(entity.Staff staff) {
        Staff.staff = staff;
    }

    /**
     * Creates a new instance of Staff
     */
    public Staff() {
    }

    public void staffByEmailName() {
        staff = staffBean.getStaffByEmailName("lam");
    }

    public String classByStaffID() {
        classes = staffBean.getClassByStaffID("ST00001");
        return null;
    }

    public String studentByClass(String classid) {
        ses = staffBean.getStudentByClass(classid);
        clid = classid;
        return null;
    }

    public String studentByName() {
        ses = staffBean.getStudentByName(clid, studentname);
        return null;
    }

    public String conection() {
        return "1";
    }

    public String assignmentByClassID(String classid) {
        Vector<Assignment> v = new Vector<Assignment>();
        Vector<Assignment> v1 = new Vector<Assignment>();
        for (int i = 0; i < staffBean.getAssignmentByClass(classid).size(); i++) {
            Assignment assignment = staffBean.getAssignmentByClass(classid).get(i);
            if (assignment.getStatus() == 1) {
                v.add(assignment);
            } else {
                v1.add(assignment);
            }
            as = v;
            as1 = v1;
        }
        return null;
    }

    public String markByAssignmentID(String assignmentid) {
        Vector<Mark> vg = new Vector<Mark>();
        Vector<Mark> vk = new Vector<Mark>();
        Vector<Mark> vtb = new Vector<Mark>();
        Vector<Mark> v = staffBean.getMarkByAssignmentIDStaff(assignmentid);
        for (int i = 0; i < v.size(); i++) {
            Mark mark = v.get(i);
            if (mark.getMark() <= 10) {
                vtb.add(mark);
            }
            if (mark.getMark() > 10 && mark.getMark() <= 20) {
                vk.add(mark);
            }
            if (mark.getMark() > 20 && mark.getMark() <= 30) {
                vg.add(mark);
            }
            msg = vg;
            msk = vk;
            mstb = vtb;
        }
        totalg = msg.size() + "/" + v.size();
        totalk = msk.size() + "/" + v.size();
        totaltb = mstb.size() + "/" + v.size();
        return null;
    }

    public String submitOfAssignmentByAssignmentID(String assignmentid) {
        soas = staffBean.getSubmitOfAssignmentByAssignmentID(assignmentid);
        return null;
    }

    public String enterMark(String assignmentid, String studentid) {
        staffBean.enterMark(assignmentid, studentid, mark);
        staffBean.updateStatusAssignment(assignmentid);
        return null;
    }
}
